﻿var repeaterControl = new RepeaterControl();
repeaterControl.HostControlID = "#RepeaterHolder";

function FlightListHandle(paras) {
    repeaterControl.HeaderTemplate ="<div><ul><li class=\"col\" style=\"background-color: rgb(170, 170, 170);\"></li></ul></div><div><ul><li class=\"col1 hd\">航空公司</li><li class=\"col1 hd\">航班号</li><li class=\"col1 hd\">机型</li><li class=\"col2 hd\">起飞时间 - 出发城市</li><li class=\"col2 hd\">到达时间 - 到达城市</li><li class=\"col1 hd\">经停</li><li class=\"col1 hd\">机建/燃油</li><li class=\"col5 hd\">电子客票</li></ul></div><div><ul><li class=\"col\" style=\"background-color: rgb(170, 170, 170);\"></li></ul></div>";
    repeaterControl.ItemTemplate = "<div><ul><li class=\"col\" style=\"background-color: rgb(170, 170, 170);\"></li></ul></div><div><ul><li class=\"col1\"><img width=\"25\" height=\"25\" src=\"/res/images/compic/{@Carrier}.gif\">{@CarrierName}</li><li class=\"col1\">{@FlightNo}</li><li class=\"col1\">{@FlightModel}</li><li class=\"col2\">{@DepTime}({@DepPortName})</li><li class=\"col2\">{@ArrTime}({@ArrPortName})</li><li class=\"col1\">{@Stop}</li><li class=\"col1\">{@TaxYQ}元</li><li class=\"col5\">支持</li></ul></div>{@subdata}";
    repeaterControl.SubItemTemplate = "<div><ul isbaseshow=\"{@isbaseshow}\"><li class=\"col4\">&nbsp;</li><li class=\"col1\">{@Discount}折舱({@Code})</li><li class=\"col3\">剩余座位 {@Seat}</li><li class=\"col3\">票面价：<strong>{@Fare}元</strong></li><li class=\"col5\"><img onclick=\"window.location.href='FlightOrder.aspx?webkey={@Webkey}&fkey={@Fkey}&ckey={@Ckey}'\" alt=\"预定该舱位\" src=\"/res/images/order.gif\"></li></ul></div>";
    var surl = "/sajax.aspx";
    SetProgree(true);
    $.ajax({
        url: surl+"?oper=getFlightList&"+paras,
        success: function(o) { 
            dataReceived(o);
            ButtonEnabled("btnSearchAir", true);
            SetProgree(false); 
        }, 
        error: reportError,
    });
}

function dataReceived(request) {
    if (request != "") {
        // bind repeater.
        repeaterControl.DataSource = request.documentElement.getElementsByTagName('flight');
        repeaterControl.DataBind();
        $("#flightresult").css("display","block");
        location.href="#top";
    }
    else {
        $(repeaterControl.HostControlID).html("");
    }
}

//  error
function reportError() {
    alert('无航班信息！');
    ButtonEnabled("btnSearchAir", true);
    SetProgree(false); 
}